package cn.iocoder.yudao.module.shop.api.appointment;

import cn.iocoder.yudao.module.shop.api.appointment.dto.AppointmentCancelReqDTO;
import cn.iocoder.yudao.module.shop.api.appointment.dto.AppointmentCreateReqDTO;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.ShopOrderCreateReqVO;
import cn.iocoder.yudao.module.shop.convert.appointment.AppointmentConvert;
import cn.iocoder.yudao.module.shop.service.order.ShopOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

@Service
@Validated
public class AppointmentApiImpl implements AppointmentApi{

    @Autowired
    private ShopOrderService orderService;

    @Override
    public Long createAppointment(AppointmentCreateReqDTO createReqDTO) {
        ShopOrderCreateReqVO shopOrderCreateReqVO = AppointmentConvert.INSTANCE.convert(createReqDTO);
        return orderService.createOrder(shopOrderCreateReqVO);
    }

    @Override
    public Boolean cancelAppointment(AppointmentCancelReqDTO cancelReqDTO) {
        orderService.cancelOrder(cancelReqDTO.getOrdreId());
        return true;
    }
}
